import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import get from '@dfeidao/atom-web/local/get';
import set from '@dfeidao/atom-web/local/set';
import fire from '@dfeidao/atom-web/msg/fire';

export default async function a003(fd: IFeidaoAiBrowserComponent, data: { hidden_source_feature_no: string; hidden_source_feature_code: string, hidden_source_feature_name: string, control_data: string; }) { // 接收隐患源特性回传数据
	// todo
	console.log('zj-000007:a005------start');
	const no = get(fd, 'source') as string;
	const odata = await fire('zj-000006', 'a001', no) as Array<{
		hidden_source_feature_no: string;
	}>;
	console.log(odata);
	console.log(data);
	let flag = true;
	odata.forEach((n) => {
		if (data.hidden_source_feature_no === n.hidden_source_feature_no) {
			flag = false;
		}
	});
	if (!flag) {
		alert('该隐患源特性已存在,请重新选择');
		return;
	} else {
		const code = fd.data.node.querySelector<HTMLInputElement>('[data-id="hidden_source_feature_code"]');
		code.value = data.hidden_source_feature_code;
		const name = fd.data.node.querySelector<HTMLInputElement>('[data-id="hidden_source_feature_name"]');
		name.value = data.hidden_source_feature_name;
		const control = fd.data.node.querySelector<HTMLInputElement>('[data-id="control_data"]');
		control.value = data.control_data;
		set(fd, 'hidden_info', data);// 保存回填的特性集的数据：隐患源特性代码、特性名称、控制数据
	}




	console.log('zj-000007:a005------end');

}
